﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ZCustomControl.Converters
{
    public class ObjectToImageSourceConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is ImageSource)
            {
                return (ImageSource)value;
            }
            else if (value is string)
            {
                ImageSource image = new BitmapImage(new Uri(System.IO.Path.Combine(Directory.GetCurrentDirectory() + @"/Images/treeicon.png"), UriKind.Absolute));
                return image;
            }
            else
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
